package com.fenghongzhang.day012eventbus;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;

import org.greenrobot.eventbus.EventBus;


/**
 * A simple {@link Fragment} subclass.
 */
public class BlankFragment extends Fragment {
    private EditText fgEd;
    private Button fgBtn;
    public BlankFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.fragment_blank, container, false);
        fgEd = (EditText) inflate.findViewById(R.id.fg_ed);
        fgBtn = (Button) inflate.findViewById(R.id.fg_btn);

        fgBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String string = fgEd.getText().toString();

                //用eventbus 发送数据
                EventBus.getDefault().post(string);
            }
        });
        return inflate;
    }
}
